<?php
/**
 * service 基类
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/11/2 0002
 * Time: 上午 11:09
 */

namespace App\Services;


class Service
{
    /**
     * @description:操作成功处理
     * @author: hkw <hkw925@qq.com>
     * @param $message
     * @param array $data
     * @return \Illuminate\Http\JsonResponse
     * @internal param string $url
     */
    protected function success($message, $data = []){
        $result = array('code' => 0, 'msg' => $message);
        //if ($data) $result['data'] = $data;
        $result['data'] = $data;
        return $result;
    }

    /**
     * @description:操作失败处理
     * @author: hkw <hkw925@qq.com>
     * @param $code
     * @param $message
     * @param array $data
     * @return \Illuminate\Http\JsonResponse
     * @internal param string $url
     */
    protected function error($code, $message, $data = []){
        $result = array('code' => $code, 'msg' => $message);
        //if ($data) $result['data'] = $data;
        $result['data'] = $data;
        return $result;
    }
}